package com.theone.module.demo.dal.mysql.testone;

import java.util.*;

import com.theone.framework.common.pojo.PageResult;
import com.theone.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.theone.framework.mybatis.core.mapper.BaseMapperX;
import com.theone.module.demo.dal.dataobject.testone.TestOneDO;
import org.apache.ibatis.annotations.Mapper;
import com.theone.module.demo.controller.admin.testone.vo.*;

/**
 * 第一个测试 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface TestOneMapper extends BaseMapperX<TestOneDO> {

    default PageResult<TestOneDO> selectPage(TestOnePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TestOneDO>()
                .likeIfPresent(TestOneDO::getName, reqVO.getName())
                .eqIfPresent(TestOneDO::getDescription, reqVO.getDescription())
                .eqIfPresent(TestOneDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(TestOneDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(TestOneDO::getId));
    }

    default List<TestOneDO> selectList(TestOneExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TestOneDO>()
                .likeIfPresent(TestOneDO::getName, reqVO.getName())
                .eqIfPresent(TestOneDO::getDescription, reqVO.getDescription())
                .eqIfPresent(TestOneDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(TestOneDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(TestOneDO::getId));
    }

}
